
cJSON *root = cJSON_Parse(json_string);
if (!root) {
    fprintf(stderr, "JSON 解析错误: %s\n", cJSON_GetErrorPtr());
    return;
}

// 获取各个字段
cJSON *type = cJSON_GetObjectItem(root, "type");
cJSON *result = cJSON_GetObjectItem(root, "result");
cJSON *data = cJSON_GetObjectItem(root, "data");

if (!type || !cJSON_IsNumber(type) ||
    !result || !cJSON_IsNumber(result) ||
    !data || !cJSON_IsArray(data)) {
    fprintf(stderr, "无效的JSON结构\n");
    cJSON_Delete(root);
    return;
}

printf("类型: %d\n", type->valueint);
printf("结果: %d\n", result->valueint);

// 检查 data 数组是否非空
if (cJSON_GetArraySize(data) > 0) {
    cJSON *data_item = cJSON_GetArrayItem(data, 0);
    if (data_item) {
        cJSON *key = cJSON_GetObjectItem(data_item, "key");
        cJSON *val = cJSON_GetObjectItem(data_item, "val");
        
        if (key && cJSON_IsNumber(key) && val && cJSON_IsString(val)) {
            printf("键: %d, 值: %s\n", key->valueint, val->valuestring);
        }
    }
}

cJSON_Delete(root);